#include "ogreapplication.h"
#include <OgreErrorDialog.h>

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Interface of MyApplication
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class MyApplication : public OgreApplication
{
public:
  MyApplication();
  virtual void keyClicked(Ogre::KeyEvent *e);
protected:
  virtual void init();  
};
using namespace Ogre;
using namespace std;

//************************************************************
// Implementation of MyApplication
//************************************************************
MyApplication::MyApplication()
  : OgreApplication("My Application")
{
}
void
MyApplication::keyClicked(KeyEvent* e)
{
  if (e->getKey() == KC_ESCAPE)
  {
    requestQuit();
    e->consume();
  }
}
void
MyApplication::init()
{
  mSceneManager->setAmbientLight(ColourValue(1,1,1));
      
  Entity *ent1 = mSceneManager->createEntity("Cube1","cube.mesh");
  SceneNode* node1 = mSceneManager->getRootSceneNode()->createChildSceneNode("Cube1Node");
  node1->attachObject(ent1);  
}

int main(int, char **)
{
  MyApplication application;
  try
  {
    application.addResourceLocationFrom("resources.cfg");
    application.create("plugins.cfg","ogre.cfg","ogre.log",ST_GENERIC);
    application.run();
  }
  catch (Exception& e)
  {
    ErrorDialog* dlg = PlatformManager::getSingleton().createErrorDialog();
    dlg->display(e.getFullDescription());
    delete dlg;
    return 1;
  }
  return 0;
}

